<template>
  <div>
    <tb-report
      :columns="columns"
      :apiUrl="apiUrl"
      :tableData="tableData"
      :getData="getData"
    ></tb-report>
  </div>
</template>

<script>
import TbReport from "@/components/tb-report/index.vue";

export default {
  name: "App",
  components: { TbReport },
  data() {
    return {
      title: "首页",
      apiUrl:"/scm/api/v1/scmPurchaseContractList/list",
      columns: [
        {
          title: "序号",
          fixed: 'left', 
          type: "seq",
          width: 60,
          align: "center",
        },
        {
          title: "需求清单号",
          key: "contractNo",
          field: "contractNo",
          width: 100,
          align: "center",
        },
        {
          title: "项目名称",
          key: "programName",
          field: "programName",
          width: 100,
          align: "center",
        },
        {
          title: "采购业务员",
          key: "purchaser",
          field: "purchaser",
          width: 100,
          align: "center",
        },
        {
          title: "状态",
          key: "purchaseStatusLabel",
          field: "purchaseStatusLabel",
          width: 100,
          align: "center",
        },
        {
          title: "项目编号",
          key: "programNumber",
          field: "programNumber",
          width: 100,
          align: "center",
        },
        {
          title: "供应商名称",
          key: "supplier",
          field: "supplier",
          width: 100,
          align: "center",
        },
        {
          title: "采购公司",
          key: "purchaseCorp",
          field: "purchaseCorp",
          width: 100,
          align: "center",
        },
        {
          title: "付款条件",
          key: "paymentCondition",
          field: "paymentCondition",
          width: 100,
          align: "center",
        },
        {
          title: "类别",
          key: "contractCategory",
          field: "contractCategory",
          width: 100,
          align: "center",
        },
        {
          title: "合同总金额",
          key: "contractAmount",
          field: "contractAmount",
          width: 100,
          align: "center",
        },
        {
          title: "合同交货日期",
          key: "deliveryDate",
          field: "deliveryDate",
          width: 100,
          align: "center",
        },
        {
          title: "采购接单日期",
          key: "generateDate",
          field: "generateDate",
          width: 100,
          align: "center",
        },
        {
          title: "追溯号",
          key: "traceBackNo",
          field: "traceBackNo",
          width: 100,
          align: "center",
        },
        {
          title: "产品信息状态",
          key: "goodsSubmitStatusLabel",
          field: "goodsSubmitStatusLabel",
          width: 100,
          align: "center",
        },
        {
          title: "关务归类状态",
          key: "entryClassifyStatusLabel",
          field: "entryClassifyStatusLabel",
          width: 100,
          align: "center",
        },
        {
          title: "项目客户",
          key: "programCustomer",
          field: "programCustomer",
          width: 100,
          align: "center",
        },
        {
          title: "项目采购经理",
          key: "purchaseManager",
          field: "purchaseManager",
          width: 100,
          align: "center",
        },
        {
          title: "申购单号",
          key: "applyBuyNo",
          field: "applyBuyNo",
          width: 100,
          align: "center",
        },
        {
          title: "申购单审批完结日期",
          key: "approvalCompletionDate",
          field: "approvalCompletionDate",
          width: 100,
          align: "center",
        },
        {
          title: "商品名称",
          key: "goodsName",
          field: "goodsName",
          width: 100,
          align: "center",
        },
        {
          title: "规格/型号",
          key: "goodsSpecificationModel",
          field: "goodsSpecificationModel",
          width: 100,
          align: "center",
        },
        {
          title: "采购数量",
          key: "purchaseQuantity",
          field: "purchaseQuantity",
          width: 100,
          align: "center",
        },
        {
          title: "成交单位",
          key: "tradeUnitLabel",
          field: "tradeUnitLabel",
          width: 100,
          align: "center",
        },
        {
          title: "用途",
          key: "purpose",
          field: "purpose",
          width: 100,
          align: "center",
        },
        {
          title: "设备位号",
          key: "equipmentItemNo",
          field: "equipmentItemNo",
          width: 100,
          align: "center",
        },
        {
          title: "子项号/成本中心代码",
          key: "childItemNo",
          field: "childItemNo",
          width: 100,
          align: "center",
        },
        {
          title: "申购人",
          key: "applyBuyPerson",
          field: "applyBuyPerson",
          width: 100,
          align: "center",
        },
        {
          title: "需求派单日期",
          key: "demandAllotDate",
          field: "demandAllotDate",
          width: 100,
          align: "center",
        },

      ],
      tableData:[]
    };
  },
  methods:{
    getData(data){
          data = data.map((item,index)=>{
              return {
                ...item,
                ...item.contractHead,
                ...item.demand,
              }
            })
           if (this.tableData.length == 0) {
            this.tableData = data;
           } else {
            this.tableData = [...this.tableData, ...data];
          }
    }
  }
};
</script>

<style>
</style>
